<?php

class loginadmin_C extends CI_Controller {
    
    function __construct()
    {
        parent::__construct();
    }
    
    function index()
    {
        $this->load->view('loginadmin_V');
    }
    
    
    function login()
    {
        $username=$this->input->post('userame');
        $password=$this->input->post('password');
        
        $sukses=$this->loginadmin_M->check_login($username, $password)->num_rows();
        
        if($sukses > 0)
        {
            $new_data=array(
                'username' => $this->loginadmin_M->check_login($username,$password)->row()->username,
                'password' => $this->loginadmin_M->check_login($username,$password)->row()->password,
                'nama_kasir' => $this->loginadmin_M->check_login($username,$password)->row()->nama_admin,
                'logged_in' => TRUE
            );
            $this->session->set_userdata($new_data);
            
            redirect('formdaftar_C/index');
        }
        
        else
        {
            echo 'Cuk';
        }
    }
    
    function logout()
    {
        $this->session->sess_destroy();
        redirect('loginadmin_C/index','refresh');
    }
}

?>
